<script setup lang="ts">
import router from "@/router";
import useDialogStore from "@/store/dialog";

//返回首页
const homePage = () => {
  router.push("/home")
}


const dialogStore = useDialogStore();

const showDialog = () => {
  dialogStore.isShow = true
}

//退出登录
const loginOut = () => {
  dialogStore.loginOut()
  router.push("/home")
}

const changeScene = () => {
  router.push({
    path: "/user/patient",
    query: {
      scene: 0
    }
  })
}

const cerOnclick = (path: string) => {
  router.push(path)
}

</script>

<template>
  <div class="top">
    <div class="content">
      <div class="left" @click="homePage">
        <img src="@/assets/images/logo.png">
        <h2>尚医通 预约挂号统一平台</h2>
      </div>

      <div class="right">
        <span>帮助中心</span>
        <span @click="showDialog" v-if="!dialogStore.userInfo.name">登录/注册</span>
        <!--用户信息展示-->
        <el-dropdown v-else>
       <span class="el-dropdown-link">
        {{ dialogStore.userInfo.name }}
      <el-icon class="el-icon--right">
        <arrow-down/>
      </el-icon>
       </span>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item @click="cerOnclick('/user/certification')">实名认证</el-dropdown-item>
              <el-dropdown-item @click="cerOnclick('/user/order')">挂号订单</el-dropdown-item>
              <el-dropdown-item @click="cerOnclick('/user/patient')">就诊人管理</el-dropdown-item>
              <el-dropdown-item @click="loginOut">退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </div>
    </div>

  </div>
</template>

<style scoped lang="less">
.top {
  position: fixed;
  z-index: 999;
  width: 100%;
  height: 70px;
  background-color: #fff;
  display: flex;
  justify-content: center;

  .content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 1200px;

    .left {
      margin-left: 10px;
      display: flex;
      align-items: center;

      img {
        margin-right: 10px;
        width: 50px;
        height: 50px;
      }
    }

    .right {
      margin-right: 10px;

      span {
        padding: 0 5px;
      }
    }
  }
}
</style>
